Skip to content

feat: code sample dark theme variant#340

Merged
greatest0fallt1me merged 3 commits into
CalloraOrg:mainfrom
vicky4196:task/code-dark-theme
Jun 29, 2026
Merged

feat: code sample dark theme variant#340
greatest0fallt1me merged 3 commits into
CalloraOrg:mainfrom
vicky4196:task/code-dark-theme

Conversation

@vicky4196

Copy link
Copy Markdown
Contributor

Add code-sample dark theme variant

Summary

This PR adds dark theme CSS variants for the CodeExample component. Code samples now respect CSS custom properties with proper light/dark theme overrides, ensuring visual parity across both modes.

Changes

src/styles/code.css (new)

  • CSS custom properties for code sample styling (--bg-subtle, --bg-highlight, --border-subtle, --text-main, --font-mono)
  • Light theme defaults for all properties
  • [data-theme="dark"] overrides for dark mode parity
  • .code-sample__tab styles with active state
  • .code-sample__pre styles for code display
  • .sr-only utility class for screen reader announcements
  • Reduced motion support via prefers-reduced-motion

src/components/CodeExample.tsx

  • Refactored from inline styles to CSS classes
  • Added import for ../styles/code.css
  • Replaced preview-card with code-sample wrapper class
  • Uses semantic class names: code-sample__header, code-sample__tabs, code-sample__tab, code-sample__tab--active, code-sample__panel, code-sample__pre
  • Removed embedded <style> block, now uses external CSS

src/components/CodeExample.test.tsx

  • Added tests for dark theme styling hooks (.code-sample class)
  • Added tests for accessible focus styles on tabs

CSS Custom Properties

Property Light Value Dark Value
--bg-subtle #f9f9f9 rgba(255, 255, 255, 0.03)
--bg-highlight #ffffff var(--surface-strong)
--border-subtle #e2e8f0 var(--line)
--text-main #1a2332 var(--text)
--font-mono SFMono-Regular stack Same

Accessibility (WCAG 2.1 AA)

  • Focus styles use var(--accent) for keyboard navigation
  • prefers-reduced-motion support for users who request reduced motion
  • Screen reader announcement for copy success via .sr-only
  • All existing ARIA attributes maintained

Test Output

✓ src/components/CodeExample.test.tsx (19 tests) 2557ms

All tests pass including:

  • Language persistence to localStorage
  • Tab keyboard navigation (arrows, Home, End)
  • Copy-to-clipboard functionality
  • Dark theme styling hooks

closes #243

- Add collapsible filter sections (Categories, Price, Popularity)
- Persist collapsed state to localStorage via usePersistedState hook
- Add ChevronIcon component for expand/collapse indicator
- Implement WCAG 2.1 AA accessibility with aria-expanded/aria-controls
- Add reduced motion support and responsive styling
- Add comprehensive tests for collapse functionality

closes CalloraOrg#254
- Add snapshotUrl.ts utility for URL-based endpoint sharing
- Add Share Snapshot button to generate/copy shareable URLs
- Restore endpoint params from URL on page load
- Add LinkIcon component for share functionality
- Handle Unicode chars in params via base64 encoding

closes CalloraOrg#252
@drips-wave

drips-wave Bot commented Jun 29, 2026

Copy link
Copy Markdown

@vicky4196 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

- Extract inline styles to code.css with CSS custom properties
- Add dark theme variants via [data-theme="dark"] selector
- Use design tokens: bg-subtle, bg-highlight, border-subtle, text-main
- Add reduced motion support and sr-only utility
- Refactor CodeExample to use semantic CSS classes

closes CalloraOrg#243
@vicky4196 vicky4196 force-pushed the task/code-dark-theme branch from d982f7b to 080eedf Compare June 29, 2026 17:07
@greatest0fallt1me greatest0fallt1me merged commit a6c59e2 into CalloraOrg:main Jun 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add code-sample dark theme variant

2 participants